import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path";
import tailwindcss from 'tailwindcss'
import optimizer from 'vite-plugin-optimizer'
const pkg = require('./package.json');

export default defineConfig({
  server: {
    proxy: {
      '/api': {
        target: 'https://teacher.dev.zyfszkj.com',
        changeOrigin: true,
      }
    }
  },
  base: './',
  define: {
    __APP_VERSION__: JSON.stringify(pkg.version)
  },
  plugins: [
    vue(),
    tailwindcss({
      config: 'tailwind.config.js', // Tailwind CSS 配置文件路径
    }),
    optimizer({
      electron: `const { ipcRenderer } = require('electron'); export { ipcRenderer };`
    }),
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src')
    },
    extensions: ['.js', '.json', '.ts', '.vue']
  },
  build: {
    outDir: './electron/dist',
    rollupOptions: {
      external: [
        // 移除或注释掉 'stream/consumers'
        // 'stream/consumers',
      ],
    },
  }
})

